package com.lagou.edu.context.util;

import org.apache.commons.lang3.StringUtils;

/**
 * @Author zhaozuowen
 * @Description
 * @Date 2020/1/7 12:39
 **/

public class StringUtil {
    /**
     * 字符串分隔符
     */
    public static final String SEPARATOR = String.valueOf((char) 29);

    /**
     * 判断字符串是否为空
     */
    public static boolean isEmpty(String str) {
        if (str != null) {
            str = str.trim();
        }
        return StringUtils.isEmpty(str);
    }

    /**
     * 判断字符串是否非空
     */
    public static boolean isNotEmpty(String str) {
        return !isEmpty(str);
    }

    /**
     * 分割固定格式的字符串
     */
    public static String[] splitString(String str, String separator) {
        return StringUtils.splitByWholeSeparator(str, separator);
    }

    /**
     * 首字母小写
     * @param str
     * @return
     */
    public static String toLowerCaseFirstOne(String str) {
        if(Character.isLowerCase(str.charAt(0)))
            return str;
        else
            return (new StringBuilder()).append(Character.toLowerCase(str.charAt(0))).append(str.substring(1)).toString();
    }
    public static String toLowerCaseFirstOne(Class classType) {
         return toLowerCaseFirstOne(classType.getSimpleName());
    }

    public static void main(String[] args) {
        String simpleName = StringUtil.class.getSimpleName();
        System.out.println(toLowerCaseFirstOne(simpleName));

    }
}
